package com.yjx.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.yjx.gulimall.common.valid.AddGroup;
import com.yjx.gulimall.common.valid.ListValue;
import com.yjx.gulimall.common.valid.UpdateGroup;
import com.yjx.gulimall.common.valid.UpdateStatusGroup;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * 商品三级分类
 * 
 * @author zhuyingcoder
 * @email 1210736981@qq.com
 * @date 2022-01-23 12:30:16
 */
@Data
@TableName("pms_category")
public class CategoryEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 分类id
	 */
	@TableId
	@NotNull(message = "分类ID不能为空", groups = {UpdateGroup.class})
	@Null(message = "分类ID必须是Null", groups = {AddGroup.class})
	private Long catId;
	/**
	 * 分类名称
	 */
	@NotBlank(message = "名称不能为空", groups = {AddGroup.class,UpdateGroup.class})
	private String name;

	/**
	 * 父分类id
	 */
	@Min(value = 0,message = "父分类Id必须是一个大于等于零的整数" ,groups = {AddGroup.class, UpdateGroup.class})
	private Long parentCid;
	/**
	 * 层级
	 */
	@ListValue(values = {1,2,3},groups = {UpdateGroup.class,AddGroup.class})
	private Integer catLevel;
	/**
	 * application.yml 配置的逻辑删除优先级 < 实体类配置逻辑删除优先级
	 * 是否显示[0-不显示，1显示]
	 */
	@TableLogic(delval = "0",value = "1")
	@ListValue(values = {0,1},groups = {UpdateStatusGroup.class,AddGroup.class,UpdateGroup.class})
	private Integer showStatus;
	/**
	 * 排序
	 */
	@Min(value = 0,message = "排序必须是一个大于零的整数" ,groups = {AddGroup.class, UpdateGroup.class})
	private Integer sort;
	/**
	 * 图标地址
	 */
	@NotBlank(message = "icon名称不能为空", groups = {AddGroup.class,UpdateGroup.class})
	private String icon;
	/**
	 * 计量单位
	 */
	@NotBlank(message = "计量单位不能为空", groups = {AddGroup.class,UpdateGroup.class})
	private String productUnit;
	/**
	 * 商品数量
	 */
	@Min(value = 0,message = "商品数量必须是一个大于等于零的整数" ,groups = {AddGroup.class, UpdateGroup.class})
	private Integer productCount;

	@TableField(exist = false)
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private List<CategoryEntity> children;


}
